dojo.provide("rptp.rpt");

dojo.require("rptp.app");
dojo.require("lotex.uri");

rptp.rpt = {
    getId: function() {
        return this.getRptIdByUrl();
    },

    getRptIdByUrl: function() {
        //return location.pathname.split("/").pop();
        // TODO Class to process location.search
        return location.search.split("definitionId=").pop();
    },

    //http://localhost:8080/rptps3/rptd!json.do
    getDefinitionURL: function() {
        return lotexConfig.baseurl
            + "/rptd!json.do?definitionId=" + this.getId();
    },

    //http://localhost:8080/rptps3/rptd!list.do
    getRptListURL: function() {
        return lotexConfig.baseurl + "/rptd!list.do";
    },

    //http://localhost:8080/rptps3/rptd!data.do
    getDatasetURL: function(rptId) {
        return lotexConfig.baseurl + "/rptd!data.do?definitionId=" + rptId;
    },

    //http://localhost:8080/rptps3/rptd!new.do
    getNewRptURL: function() {
        return lotexConfig.baseurl + "/rptd!new.do";
    },

    //http://localhost:8080/rptps3/rptd!edit.do?definitionId=4028807c0f557272010f55c8738f0005
    getInputFormURL: function() {
        return lotexConfig.baseurl
            + "/rptd!edit.do?definitionId=" + this.getId();
    },

    //http://localhost:8080/rptps3/rpt/4028807c0f557272010f55c8738f0005
    getEditWindowURL: function(docID, revision, invitation, prefix) {
        return lotexConfig.baseurl + "/rpt/" + docID;
    },

    //http://localhost:8080/rptps3/rptd!datasetForm.do
    getDatasetFormURL: function() {
        return lotexConfig.baseurl + "/rptd!datasetForm.do";
    },

    createNewRpt: function() {
    }
};